package com.example.idachuappone.index.entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class Comment implements Serializable {
    private String bespeak_id;
    private String content;
    private String dateline;
    private String id;
    private List<CommentImg> imgs;
    private String star;
    private CommentUser user;

    public Comment parseJson(JSONObject json) {
        if (json == null) {
            return null;
        }
        if (json.has("id")) {
            this.id = json.optString("id");
        }
        if (json.has("star")) {
            this.star = json.optString("star");
        }
        if (json.has("bespeak_id")) {
            this.bespeak_id = json.optString("bespeak_id");
        }
        if (json.has("content")) {
            this.content = json.optString("content");
        }
        if (json.has("dateline")) {
            this.dateline = json.optString("dateline");
        }
        if (json.has("dateline")) {
            this.dateline = json.optString("dateline");
        }
        if (json.has("imgs")) {
            JSONArray jsonArray = json.optJSONArray("imgs");
            this.imgs = new ArrayList();
            for (int i = 0; i < jsonArray.length(); i++) {
                try {
                    JSONObject jsonObject = jsonArray.getJSONObject(i);
                    this.imgs.add(new CommentImg().parseJson(jsonObject));
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
        }
        if (!json.has("user")) {
            return this;
        }
        try {
            this.user = new CommentUser().parseJson(json.getJSONObject("user"));
            return this;
        } catch (JSONException e2) {
            e2.printStackTrace();
            return this;
        }
    }

    public String getId() {
        return this.id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getStar() {
        return this.star;
    }

    public void setStar(String star) {
        this.star = star;
    }

    public String getBespeak_id() {
        return this.bespeak_id;
    }

    public void setBespeak_id(String bespeak_id) {
        this.bespeak_id = bespeak_id;
    }

    public String getContent() {
        return this.content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getDateline() {
        return this.dateline;
    }

    public void setDateline(String dateline) {
        this.dateline = dateline;
    }

    public CommentUser getUser() {
        return this.user;
    }

    public void setUser(CommentUser user) {
        this.user = user;
    }

    public List<CommentImg> getImgs() {
        return this.imgs;
    }

    public void setImgs(List<CommentImg> imgs) {
        this.imgs = imgs;
    }
}
